import { create } from "zustand";

export interface UserInfo {
  userId: string | number;
  userName: string;
  userEmail: string;
  deptId: string;
  state: number;
  mobile: string;
  job: string;
  role: number;
  roleList: string;
  createId: number;
  deptName: string;
  userImg: string;
}

export default create<{
  token: string;
  userInfo: UserInfo;
  updateToken: (token: string) => void;
  updateUserInfo: (userInfo: UserInfo) => void;
}>((set) => ({
  token: "",
  userInfo: {
    userId: 0,
    userName: "",
    userEmail: "",
    deptId: "",
    state: 0,
    mobile: "",
    job: "",
    role: 0,
    roleList: "",
    createId: 0,
    deptName: "",
    userImg: "",
  },
  updateToken: (token) => set({ token }),
  updateUserInfo: (userInfo: UserInfo) => set({ userInfo }),
}));
